[IA64] Speedup ptc.e emulation
authorAlex Williamson <alex.williamson@hp.com>
Sun, 15 Jul 2007 19:40:47 +0000 (13:40 -0600)
committerAlex Williamson <alex.williamson@hp.com>
Sun, 15 Jul 2007 19:40:47 +0000 (13:40 -0600)
This patch makes ptc.e emulation faster.
It defers the initialization of collision chain area of VHPT.
Also removes an unused field from struct thash_cb.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
xen/arch/ia64/vmx/vtlb.c
xen/include/asm-ia64/vmmu.h

index 8fa6b4c598291ac1dbaabfe3a5c31aeed1b68b84..0348bc3416a9287d4b36c3b2eeb865a39728b7d2 100644 (file)
 
 thash_data_t *__alloc_chain(thash_cb_t *);
 
-static void cch_mem_init(thash_cb_t *hcb)
+static inline void cch_mem_init(thash_cb_t *hcb)
 {
-    int num;
-    thash_data_t *p;
-
-    hcb->cch_freelist = p = hcb->cch_buf;
-    num = (hcb->cch_sz/sizeof(thash_data_t))-1;
-    do{
-        p->next =p+1;
-        p++;
-        num--;
-    }while(num);
-    p->next = NULL;
+    hcb->cch_free_idx = 0;
+    hcb->cch_freelist = NULL;
 }
 
 static thash_data_t *cch_alloc(thash_cb_t *hcb)
@@ -56,8 +47,16 @@ static thash_data_t *cch_alloc(thash_cb_t *hcb)
     thash_data_t *p;
     if ( (p = hcb->cch_freelist) != NULL ) {
         hcb->cch_freelist = p->next;
+        return p;
+    }
+    if (hcb->cch_free_idx < hcb->cch_sz/sizeof(thash_data_t)) {
+        p = &((thash_data_t *)hcb->cch_buf)[hcb->cch_free_idx++];
+        p->page_flags = 0;
+        p->itir = 0;
+        p->next = NULL;
+        return p;
     }
-    return p;
+    return NULL;
 }
 
 /*
@@ -668,13 +667,12 @@ thash_data_t *vtlb_lookup(VCPU *v, u64 va,int is_data)
 void thash_init(thash_cb_t *hcb, u64 sz)
 {
     int num;
-    thash_data_t *head, *p;
+    thash_data_t *head;
 
     hcb->pta.val = (unsigned long)hcb->hash;
     hcb->pta.vf = 1;
     hcb->pta.ve = 1;
     hcb->pta.size = sz;
-    hcb->cch_rec_head = hcb->hash;
     
     head=hcb->hash;
     num = (hcb->hash_sz/sizeof(thash_data_t));
@@ -686,16 +684,7 @@ void thash_init(thash_cb_t *hcb, u64 sz)
         head++;
         num--;
     }while(num);
-    
-    hcb->cch_freelist = p = hcb->cch_buf;
-    num = hcb->cch_sz / sizeof(thash_data_t);
-    do{
-        p->page_flags = 0;
-        p->itir = 0;
-        p->next =p+1;
-        p++;
-        num--;
-    }while(num);
 
-    (p - 1)->next = NULL;
+    hcb->cch_free_idx = 0;
+    hcb->cch_freelist = NULL;
 }
index 668a0ceb9674cc03f28ebd2ca010d1004948419f..90f160605dad3f1e2f0164a8a469b44d18683f31 100644 (file)
@@ -196,8 +196,8 @@ typedef struct thash_cb {
     u64     hash_sz;        // size of above data.
     void    *cch_buf;       // base address of collision chain.
     u64     cch_sz;         // size of above data.
+    u64     cch_free_idx;   // index of free entry.
     thash_data_t *cch_freelist;
-    thash_data_t *cch_rec_head;  // cch recycle header
     PTA     pta;
 } thash_cb_t;